<template>
	<div class="jk-divider-card" :style="{ borderColor: borderColor}">
		<div class="jk-divider-card-header" :style="setPlacement(placement)">
			<span :class="icon" style="margin-right: 4px;"></span>
			<span>{{ title }}</span>
		</div>
		<div class="jk-divider-card-content">
			<slot></slot>
		</div>
	</div>
</template>
<script>
    export default {
        name: 'JkDividerCard',
        props: {
            title: {
                type: String,
                default: '基础信息'
            },
            borderColor: {
                type: String,
                default: '#dcdee2'
            },
            icon: {
                type: String,
                default: 'el-icon-tickets'
            },
            placement: {
                type: String,
                default: 'left'
            },
            titleStyle: {
                type: Object,
                default() {
                    return {};
                }
            }
        },
        methods: {
            setPlacement(type) {
                if (type === 'center') {
                    return {
                        transform: 'translateX(-50%) translateY(-50%)',
                        left: '50%',
                        ...this.titleStyle
                    };
                } else {
                    return {
                        transform: 'translateX(16px) translateY(-50%)',
                        left: '0%',
                        ...this.titleStyle
                    };
                }
            }
        }
    };
</script>
<style scoped lang="scss">
    .jk-divider-card {
        //margin-top: 20px;
        box-shadow: 0 0 2px 0 #eee;
        border-radius: 8px;
        border: 1px solid #dcdee2;
        background: #fff;
        position: relative;
        .jk-divider-card-header {
            position: absolute;
            font-size: 14px;
            background: #fff;
            padding: 2px 20px;
            color: #303133;
            border-radius: 4px;
        }
        .jk-divider-card-content {
            padding: 22px 16px 16px 16px;
        }
    }
    .jk-divider-card:hover {
        box-shadow: 0 0 10px 2px #eee;
        transition: all .5s;
    }
</style>
